import { defineStore } from "pinia";
import { Ajax } from "@/api";

export const useStore = defineStore("main", {
  state: () => {
    return {
      number: 2209,
      userInfo: null,
      isCollapse: false, // 是否收起来
      roleList: [], //权限列表
      userList: [], //用户列表
    };
  },
  getters: {},
  actions: {
    numberAdd() {
      this.number++;
      console.log(this.number);
    },
    setisCollapse(payload: any) {
      this.isCollapse = payload;
    },
    setUserInfo(payload: any) {
      this.userInfo = payload;
    },
    async changeUserInfo(payload?: any) {
      let { result } = await Ajax.getuserinfo(payload);
      this.userInfo = result;
    },

    async changeRoleList(payload: any) {
      let { result } = await Ajax.getrolelist();
      this.changeUserInfo(payload);
      this.roleList = result;
    },
    async getUserList(payload?: any) {
      let { result } = await Ajax.userlist(payload);
      this.userList = result;
    },
    changeUserList(payload?: any) {
      this.userList = payload;
    },
  },
});
